import type { ColumnsType } from "@/components";
import { ElText } from "element-plus"
import { h } from "vue"

/** 请求类型 */
export const REQUEST_TYPE = {
    1: "GET",
    2: "POST"
}

/** 启用状态 */
export const ENABLE_STATE = new Map([
    [true, "启用"],
    [false, "禁用"]
])

/** 表格配置 */
export const columns: ColumnsType[] = [
    {
        width: 100,
        label: "ID",
        prop: "Id"
    },
    {
        minWidth: 100,
        label: "角色名称",
        prop: "Name"
    },
    {
        width: 100,
        label: "角色等级",
        prop: "Sort"
    },
    {
        width: 100,
        label: "状态",
        prop: "Enable",
        formatter(row, column, cellValue, index) {
            return h(ElText, {
                type: cellValue ? 'primary' : 'danger'
            }, () => ENABLE_STATE.get(cellValue) ?? "未知")
        },
    },
    {
        label: "角色描述",
        prop: "Desc"
    },
    {
        fixed: "right",
        width: 140,
        label: "编辑角色",
        prop: "Operation",
        Slots: {
            default: "Operation"
        }
    },
    {
        fixed: "right",
        width: 100,
        label: "编辑权限",
        prop: "EditAuth",
        Slots: {
            default: "EditAuth"
        }
    },
]